#include <fstream>
#include <string>
#include <iostream>

#include "LexicalAnalyzer.h"

int main(int argc, char** argv)
{
	std::cout << argc << std::endl;
	if (argc <= 2) 
	{
		return -1;
	}
	std::cout << argv[1] << ' ' << argv[2] << std::endl;
//	system("pause");
	std::ifstream ifs(argv[1], std::ios::in | std::ios::binary);
	lexical_analyzer lex(ifs);
	std::ofstream ofs(argv[2]);
	std::ostream& os = std::cout;
	token t;
	lexical_status status;
	while ((status = lex.get_token(t)) != status_eof)
	{
		if (status == status_success)
		{
			ofs << lex.get_current_index() << "@@@" << t.value << '\n';
			os << lex.get_current_index() << "@@@" << t.value << '\n';
		}
		else if (status == status_invalid_char)
		{
			std::cerr << "Line:" << lex.get_current_line() << "invalid_char: " << t.value << '\n';
		}
	}
//	os << lex.str << std::endl;

//	system("pause");
	return 0;
}